#include <bits/stdc++.h>
// 2025/01/19
// tag: 
// Author: Zhang Muen
using namespace std;

int n, a[5001];
int64_t cnt = 0;

typedef unsigned long long ll;

ll C(ll n, ll m)
{
    if (m > n)
        return 0;
    ll result = 1;
    for (ll i = 1; i <= m; ++i)
    {
        result = result * (n - m + i) / i;
    }
    return result;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    int p;
    for (int i = 1; i <= n; i++)
        cin >> p, a[p]++;
    for (int i = 1; i <= 5000; i++)
        if (a[i] >= 2){
            for (int j = 1; j <= i / 2; j++)
                if (j != i - j)
                    cnt += C(a[i], 2) * C(a[j], 1) * C(a[i - j], 1), cnt %= 1000000007;
                else
                    cnt += C(a[i], 2) * C(a[j], 2), cnt %= 1000000007;
        }
    cout << cnt;
    return 0;
}